import axios from 'axios'

axios.interceptors.request.use(config => {
  //config是axios配置对象
  //每次发送请求前都会进入此拦截器处理函数，可以在此处统一携带上token，每次请求都会自
  /* config.headers.common['token'] = window.localStorage.getItem("accessToken");*/
  /*if (window.localStorage.getItem("accessToken")==""||window.localStorage.getItem("accessToken")==null){
    this.$router.push("/");
  } else {
    config.headers.common['Authorization']=`Bearer `+window.localStorage.getItem("accessToken");
  }*/
  console.log("123456")
  return config
},err => {
  //请求出错的处理函数
  return Promise.reject(err)
})

const request=axios.create({
  baseURL: 'http://localhost:8082/',
  timeout: 6000,
  headers: {
    Authorization: `Bearer `+window.localStorage.getItem("accessToken"),
  },
});

export  default  request;



